from page_objects.login_page import LoginPage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait  # 导入显式等待类
from selenium.webdriver.support import expected_conditions as EC

class ShangjiaPage(LoginPage):
    # 元素定位器
    # 1.定位支付管理
    pay_manage_loc=(By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[7]/h2')
    # 2.定位支付产品信息
    pay_info_loc=(By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[8]/ul/li[1]/div/a')
    # 3.定位添加产品按钮
    add_product_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[2]/div[1]/ul/li[1]/a')
    # 4.定位支付产品编码框
    product_code_loc=(By.NAME,'productCode')
    # 5.定位支付产品名称
    product_name_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[3]/div/form/div[1]/div/fieldset/dl[2]/dd/input')
    # 6.定位提交
    commit_loc=(By.XPATH,'//*[@id="navTab"]/div[2]/div[3]/div/form/div[2]/ul/li[1]/div/div/button')
    # 7.定位设置支付方式
    pay_fs_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[2]/div[2]/div[2]/div/table/tbody/tr[1]/td[6]/div/a[1]')
    # 8.定位设置支付方式2
    pay_fs2_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[3]/div[2]/div[1]/ul/li[1]/a')
    # 9.定位支付费率输入框
    payRate_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[4]/div/form/div[1]/div/fieldset/dl[3]/dd/input')
    # 10.定位提交
    fs_commit_loc = (By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[4]/div/form/div[2]/ul/li[1]/div/div/button')
    # 删除支付方式
    delete_fs_loc = (By.LINK_TEXT, ' 删除')
    # 11.定位上架
    sj_loc = (By.LINK_TEXT, '上架')
    # 12.定位确定
    qd_loc = (By.XPATH, '/html/body/div[13]/div[1]/div/div[2]/ul/li[1]/a/span')
    # 断言1-龙果支付后台
    dy1_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[1]/div/p[1]/span')
    # 断言2-确定要上架吗?-支付方式未设置，无法操作！
    dy2_loc = (By.XPATH,'/html/body/div[13]/div[1]/div/div[1]/div')
    # 断言3-添加产品后页面显示的数据是否和数据库一致
    dy3_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[2]/div[2]/div[2]/div/table/tbody/tr[1]/td[3]/div')
    # 断言4-添加产品支付方式，是否和数据库同步
    dy4_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[3]/div[2]/div[2]/div[2]/div/table/tbody/tr/td[3]/div')
    # 断言4-添加产品支付费率，是否和数据库同步
    dy5_loc = (By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[3]/div[2]/div[2]/div[2]/div/table/tbody/tr/td[6]/div')

    # 封装元素的操作方法
    # 1.点击支付管理
    def click_pay_manage(self):
        self.click(self.pay_manage_loc)
        return self

    # 2.点击支付产品信息
    def click_info_loc(self):
        self.click(self.pay_info_loc)
        return self

    # 3.点击添加产品
    def click_add_product(self):
        self.click(self.add_product_loc)
        return self

    # 4.输入支付产品编码
    def input_product_code(self,product_code):
        self.send_keys(self.product_code_loc,product_code)
        return self

    # 5.输入支付产品名称
    def input_product_name(self,product_name):
        self.send_keys(self.product_name_loc,product_name)
        return self

    # 6.点击提交
    def click_commit(self):
        self.click(self.commit_loc)
        return self

    # 7.定位设置支付方式
    def click_pay_fs(self):
        self.click(self.pay_fs_loc)
        return self

    # 8.定位设置支付方式2
    def click_pay_fs2(self):
        self.click(self.pay_fs2_loc)
        return self

    # 9.输入支付费率
    def input_payRate(self,payRate):
        self.send_keys(self.payRate_loc,payRate)
        return self

    # 10.点击提交
    def click_fs_commit(self):
        self.click(self.fs_commit_loc)
        return self

    # 点击删除支付渠道
    def delete_qd(self):
        self.click(self.delete_fs_loc)
        return self

    # 11.点击上架
    def click_sj(self):
        self.click(self.sj_loc)
        return self

    # 12.点击确定
    def click_qd(self):
        self.click(self.qd_loc)
        return self